CC=gcc
CXX=g++
CFLAGS=-Wall $(DEBUG) $(DEFINITIONS) $(CINCLUDES) $(CMISCFLAGS) $(CE)
CPPFLAGS=-Wall $(DEBUG) $(CPPINCLUDES) $(DEFINITIONS) $(CPPMISCFLAGS) $(CE)
DEBUG=-O0 -g3
CMISCFLAGS=
CPPMISCFLAGS=
DEFINITIONS=-DLINUX_OS

CINCLUDES=$(INCGIMI)
CPPINCLUDES=$(INCGIMI) $(MACI_INCLUDE_PATHS) $(MACI_EXT_INCLUDE_PATHS) \
						`wx-config --cflags` \
						-I ../../\
						-I ../MapViewer
#CPPINCLUDES=-I. -I$(GDIR)/Gimbo  -I$(GDIR)/GIMUI $(MACI_INTERFACE_MAP_EXT_INCLUDE) \
#%`xml2-config --cflags` $(INCGIMI) $(MACI_INCLUDE_PATHS) \
#`wx-config --cflags --unicode=no` \
#-I$(GDIR)/Gimbo/components/MapViewer

LD=g++
LDFLAGS=
LIBS=-lrt -lpthread -lGL -lglut `xml2-config --libs` `wx-config --libs std,gl --unicode=no` \
$(LIBSGIMI) $(MACI_INTERFACE_MAP_EXT_LIBS)
GDIR=../../..
MACIPATH=$(GDIR)/MaCI
SRCSC=
SRCSCPP=main.cpp Machine.cpp Device.cpp Devices.cpp MuRo_Frames.cpp	\
MuRoMainFrame.cpp MuRoHelpFrame.cpp MuRoSettingsFrame.cpp						\
../../Component.cpp GLDisplay.cpp RangingDisplay.cpp								\
picking/glutils.cpp picking/picking.cpp Group.cpp DrivePath.cpp			\
$(GDIR)/Gimbo/components/MapViewer/MapDisplay.cpp										\
$(MACIPATH)/interfaces/Map/Mapper.cpp AlarmBalloon.cpp							\
MuRo_QuestionFrame.cpp MuRo_AlarmFrame.cpp

VPATH=
CPPGIMI=
CGIMI=

## Build GIMI and it's dependencies.
## Files are set to CGIMI and CPPGIMI variables
include $(GDIR)/GIMI/Makefile.gimi

include $(GDIR)/MaCI/interfaces/MaCI-interfaces.Makefile

## Construct final lists of CPP and C objects
OBJS_C=$(SRCSC:.c=.o)
OBJS_CPP=$(SRCSCPP:.cpp=.opp)
OBJSC=$(CGIMI:.c=.o) $(MACI_INTERFACE_MAP_EXT_C:.c=.o)
OBJSCPP=$(CPPGIMI:.cpp=.opp) \
			$(MACI_BASE_SRC_CPP:.cpp=.opp) \
			$(MACI_EXT_SRC_CPP:.cpp=.opp) \
			$(MACI_INTERFACE_RANGING_COMMON_CPP:.cpp=.opp) \
			$(MACI_INTERFACE_RANGINGCLIENT_CPP:.cpp=.opp) \
			$(MACI_INTERFACE_SPEEDCTRL_COMMON_CPP:.cpp=.opp) \
			$(MACI_INTERFACE_SPEEDCTRLCLIENT_CPP:.cpp=.opp) \
			$(MACI_INTERFACE_POSITION_COMMON_CPP:.cpp=.opp) \
			$(MACI_INTERFACE_POSITIONCLIENT_CPP:.cpp=.opp) \
			$(MACI_INTERFACE_COORDINATEDRIVE_COMMON_CPP:.cpp=.opp) \
			$(MACI_INTERFACE_COORDINATEDRIVECLIENT_CPP:.cpp=.opp) \
			$(MACI_INTERFACE_MAP_COMMON_CPP:.cpp=.opp) \
			$(MACI_INTERFACE_MAPCLIENT_CPP:.cpp=.opp) \
			$(MACI_INTERFACE_MAP_EXT_CPP:.cpp=.opp) \
			$(MACI_INTERFACE_ALARM_COMMON_CPP:.cpp=.opp) \
			$(MACI_INTERFACE_ALARMCLIENT_CPP:.cpp=.opp) \
			$(MACI_INTERFACE_ENERGY_COMMON_CPP:.cpp=.opp) \
			$(MACI_INTERFACE_ENERGYCLIENT_CPP:.cpp=.opp)

## Define compiles and links
COMPILEC=$(CC) $(CFLAGS) $(CINCLUDES) -c
COMPILECPP=$(CXX) $(CPPFLAGS) $(CPPINCLUDES) -c
LINK=$(LD) $(LDFLAGS)

.PHONY: all clean

all: MuRo

MuRo: $(OBJSC) $(OBJSCPP) $(OBJS_C) $(OBJS_CPP)
	@$(LINK) -o $@ $(OBJSC) $(OBJSCPP) $(OBJS_C) $(OBJS_CPP) $(LIBS)
	@echo "      [LD] $@"

clean:
	rm -f $(OBJS_C) $(OBJS_CPP) MuRo *.out *~ *.d *.dpp

realclean: clean
	rm -f $(OBJSC) $(OBJSCPP) *.out *~ *.d *.dpp

## Below this is dependency generation stuff, no need to change.
## Compile rule for all .o (.c) file
%.o:    %.c
	@$(COMPILEC) -o $@ $<
	@echo "      [CC] $<"

## Compile rule for all .opp (.cpp) files
%.opp:  %.cpp
	@$(COMPILECPP) -o $@ $<
	@echo "      [CXX] $<"
